package edu.ycxy.poetry.service.serviceImpl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.ycxy.poetry.entity.DjInfo;
import edu.ycxy.poetry.mapper.DjInfoMapper;
import edu.ycxy.poetry.service.IDjInfoService;
import edu.ycxy.poetry.vo.UpdateDjVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author @xin
 * @createDate 2022/3/14
 * @Description
 */
@Service
public class DjInfoServiceImpl extends ServiceImpl<DjInfoMapper, DjInfo> implements IDjInfoService {

    @Autowired
    private DjInfoMapper djInfoMapper;

    //根据id查询详细的内容
    @Override
    public List<DjInfo> selectList(Integer aid) {
        return djInfoMapper.selectList(aid);
    }

    //根据aid查询出来的主标题,获取每个数据的次标题
    @Override
    public List<DjInfo> selectListById(Integer id) {
        return djInfoMapper.selectLisTById(id);
    }

    //根据古籍的章节目录的id查询该目录里面的详细内容
    @Override
    public DjInfo findContentById(Integer id) {
        return djInfoMapper.findContentById(id);
    }

    /**
     * 模糊查询
     * @param title 查询条件
     * @param pageNum 分页页码
     * @param pageSize 分页数量
     * @return pageInfo
     */
    @Override
    public PageInfo<DjInfo> findFuzzy(String title, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<DjInfo> fuzzy = djInfoMapper.findFuzzy(title);
        PageInfo<DjInfo> djInfoPageInfo = new PageInfo<>(fuzzy);
        return djInfoPageInfo;
    }


    @Override
    public Integer deleteDjInfoById(Integer id) {
        Integer integer = djInfoMapper.deleteDjInfoById(id);
        return integer;
    }

    @Override
    public Integer updateDjInfo(UpdateDjVo updateDjVo) {
        return djInfoMapper.updateDjInfo(updateDjVo);
    }


}
